// 使用mysql2模块
const mysql = require('mysql2')
    //连接数据库
const connection = mysql.createConnection({
    host: 'localhost', //主机
    user: "root", //用户名
    password: "root", //自己设置的密码
    database: "student", //表名
    charset: "utf8"
})
async function fn() {
    let sql = "SELECT * FROM products";
    let [rows] = await connection.promise().query(sql);
    console.log(rows);
}
fn()